/*
 * Powered By fanrenqij.com
 * Since 2017 - 2017
 */

package com.fanrenqiji.modules.business.event.dao;

import com.fanrenqiji.common.persistence.BaseDao;
import com.fanrenqiji.common.persistence.BaseDaoImpl;
import com.fanrenqiji.entity.EventDetailEntity;
import com.fanrenqiji.entity.EventEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 持久化接口
 */
public interface EventDetailDao extends EventDetailDaoCustom, CrudRepository<EventDetailEntity, Long> {

    @Query("from EventDetailEntity where delFlag='" + EventDetailEntity.DEL_FLAG_NORMAL + "' order by id desc")
    public List<EventDetailEntity> findAllList();


    @Query("from EventDetailEntity where delFlag='" + EventDetailEntity.DEL_FLAG_NORMAL + "' and status =?1 order by id")
    public List<EventDetailEntity> findEventDetailEntityByStatus(int status);

    @Modifying
    @Query("update EventDetailEntity set delFlag='" + EventDetailEntity.DEL_FLAG_DELETE + "' where id = ?1 ")
    void deleteById(Long id);


    @Query("from EventDetailEntity where delFlag='" + EventDetailEntity.DEL_FLAG_NORMAL + "' and event.id =?1 and semester.id=?2 ")
    public EventDetailEntity findEventDetail(Long eventId,Long semesterId);

}


interface EventDetailDaoCustom extends BaseDao<EventDetailEntity> {
}

@Repository
class EventDetailDaoImpl extends BaseDaoImpl<EventDetailEntity> implements EventDetailDaoCustom {

}
